//
//  uStationSelector.h
//  ElektroM
//
//  Created by Michael on 20.10.09.
//  Copyright 2009 Artgruppe inc. All rights reserved.
//

#import <UIKit/UIKit.h>

@class undergroundController;
@class dataBase;
@interface uStationSelector : UIViewController <UINavigationBarDelegate,UITableViewDelegate,
								UISearchBarDelegate> {	
	IBOutlet UITableView* table;	
	
	IBOutlet UIBarButtonItem* navTitle;
	IBOutlet UIBarButtonItem* leftButton;									
	IBOutlet UISearchBar*	searchBar;
	
	NSUInteger _nCount;	
	
	NSUInteger _nSegmentSelected;	///! did we choose sorting the lines or showing the directions;
	bool _bSearchInProgress;
	NSUInteger* _anIndexesStFound;
	NSUInteger _nSearchedStations;
	
	dataBase* _db;

	UIImage** _aImagesForLines;

	// iApple-section :)
	// recreate with indexes and the stuff...
	NSArray* 	_aiULineNames;	//used as _strULineNames substitute;
	NSDictionary*	_diAllStationsWithIndexes;
	NSDictionary* 	_diSortedLineNumbers;
	NSArray* 	_aiStationsInLineCount;
	NSArray* 	_aiSortedLettersForUSt;
	NSDictionary* 	_diSortedStationIds;
	NSArray* 	_aiAllStationNames;
	NSArray* 	_aiAllStationIds;
	NSArray* 	_aiAllStationLineIds;
	//NSArray* _aiAllStationIdsBeforeSort;
	NSDictionary*	_diStationSortedByLineNames;
	NSDictionary* 	_diStationIdsSortedByLineNames;
	NSArray* 	_aiLineIdsUsedInSortingByLines;
	//NSArray* _aiLineNamesUsedInSortingByLines;
	// end of that iApple-section;									
	
	undergroundController* myMaster;									
	bool 		_bSearchWasPerformed;

	NSString* 	strSearch;
}
@property (nonatomic, retain) IBOutlet UIBarButtonItem* navTitle;
@property (nonatomic, retain) IBOutlet UIBarButtonItem* leftButton;

@property (nonatomic, retain) IBOutlet UITableView* table;
@property (nonatomic, retain) IBOutlet UISearchBar* searchBar;
@property (nonatomic, retain) NSString* strSearch;

// methods for getting info about the stations:
-(void) readAll;
-(void) readForTheLine:(int)lineNum;

-(IBAction) goBack;
-(void)setStationsInfo:(NSArray*)aLines
		 withCount:(int)count 
		 andController:(undergroundController*)controller 
		 andDb:(dataBase*)db;
		 /*
-(void) setStationsInfo:(NSString**)st 
			  withCount:(int)count 
		  andController:(undergroundController*)controller 
				  andDb:(dataBase*)db	
		   andLineNames: (NSString**)lines
		 andLineNumbers: (NSUInteger*)numbers;
		 */
-(IBAction)segmentAction:(id)sender;
-(void) releaseUnneededElements;
-(void) loadAllNeededElements:(dataBase*)db;
-(void) performSearch: (NSString*) searchText;
@end
